package com.yfp.operation.controller;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.yfp.common.core.domain.R;
import com.yfp.operation.domain.PositionSharing;
import com.yfp.operation.service.WxService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 微信业务
 * 
 * @CreateDate: 2024/7/3 11:44
 * @UpdateUser: 
 * @UpdateDate: 2024/7/3 11:44
 * @UpdateRemark: 暂无修改
 * @Version: 1.0
 */
@RestController
@RequestMapping("/wx")
@Tag(name = "微信业务")
@Slf4j
public class WxController {
    @Autowired
    private WxService wxService;

    @Operation(summary = "添加分账关系")
    @PostMapping("/addReceiver")
    public R<Void> addReceiver(@RequestBody List<PositionSharing> positionSharing) {
        try {
            wxService.addReceiver(positionSharing);
        } catch (WxPayException e){
            return R.fail(e.getMessage());
        }
        return R.ok();
    }
}
